/* 封装ajax */
var ajax = function(url,type,data){
	var res = null;
	return new Promise((reslove,reject)=>{
		mui.ajax({
			url:__host+url,
			type: type,
			data : data?data:{},
			contentType:"application/json",
			success: function(data) {
				reslove(data)
			},
			error: function(xhr, type, errorThrown) {
				mui.hideLoading()
				mui.toast(type+"："+errorThrown)
				reject()
			},
			complete: function (xhr) {
				if(xhr.getResponseHeader("sessionstatus") == "timeout"){
					mui.hideLoading()
					location.href = "#/login"
				}			}
		});
	})
}

export default ajax